#pragma once
#include <windows.h>
#include "IListener.h"

enum eType{HERO, BULLET, UNIT, STRUCTURE, RESOURCE, LEVEL_COLLISION, TYPE};
class CEvent;

class CBase : public IListener
{
	unsigned int m_uiRefCount;
	float m_fPosX;
	float m_fPosY;
	float m_fOldPosX;
	float m_fOldPosY;
	float m_fVelX;
	float m_fVelY;
	unsigned int m_nWidth;
	unsigned int m_nHeight;

protected:
	int m_nType;

public:

	//Accessors
	int GetType() {return m_nType;}
	float GetPosX() {return m_fPosX;}
	float GetPosY() {return m_fPosY;}
	float GetOldPosX() {return m_fOldPosX;}
	float GetOldPosY() {return m_fOldPosY;}
	float GetVelX() {return m_fVelX;}
	float GetVelY() {return m_fVelY;}
	int GetWidth() {return m_nWidth;}
	int GetHeight() {return m_nHeight;}
	float GetHalfWidth() {return (float)(m_nWidth >> 1);}
	float GetHalfHeight() {return (float)(m_nHeight >> 1);}

	//Mutators
	void SetPosX(float X) {m_fPosX = X;}
	void SetPosY(float Y) {m_fPosY = Y;}
	void SetOldPosX(float X) {m_fOldPosX = X;}
	void SetOldPosY(float Y) {m_fOldPosY = Y;}
	void SetType(int Type) {m_nType = Type;}
	void SetVelX(float VelX) {m_fVelX = VelX;}
	void SetVelY(float VelY) {m_fVelY = VelY;}
	void SetWidth(int width) {m_nWidth = width;}
	void SetHeight(int height) {m_nHeight = height;}

	CBase();
	virtual ~CBase();

	virtual void Init();
	virtual void Update(float fDelta);
	virtual void Render();
	void AddRef()
	{
		m_uiRefCount++;
	}
	void Release()
	{
		m_uiRefCount--;

		if (m_uiRefCount == 0)
			delete this;
	}
	RECT GetCollisionRect();
	RECT GetDrawRect();
	virtual bool Collision(CBase* pBase);
	virtual void HandleEvent(CEvent* pEvent);
};